package 极客时间.concurrence.并发编程实战篇.手写一把lock.细节回顾;

import java.util.concurrent.atomic.AtomicReference;

/**
 * @Author idea
 * @Date created in 10:11 下午 2020/7/22
 */
public class AtomicReferenceDemo {

    public static void main(String[] args) {
        String oldWord = "old content";
        String newWord = "new content";
        AtomicReference<String> atomicReference = new AtomicReference<>(oldWord);
        boolean result = atomicReference.compareAndSet(oldWord,newWord);
        System.out.println("此时的新值为："+atomicReference.get()+" result is :"+result);
        result = atomicReference.compareAndSet(oldWord,newWord+"1");
        System.out.println("此时的新值为："+atomicReference.get()+" result is :"+result);

    }
}
